<?php

/**
 *  合同mo'ban 
 * Created by PhpStorm.
 * User: Apache
 * Date: 2019/10/27
 * Time: 10:02
 */
namespace app\api\controller\basemanage;
use app\api\controller\common\ApiBase;
use think\Controller; // den
use think\Db;

class Config extends ApiBase
{
    //合同模板编辑删除
    public function edit()
    {
        if (request()->isPost()) {
            $post = input('post.');
            $about_us_text = isset($post['about_us_text']) && $post['about_us_text'] != '' ? $post['about_us_text'] : null;
            $about_us_path = isset($post['about_us_path']) && $post['about_us_path'] != '' ? $post['about_us_path'] : null;
            $about_us_type = isset($post['about_us_type']) && $post['about_us_type'] != '' ? $post['about_us_type'] : 1;
            $reminder = isset($post['reminder']) && $post['reminder'] != '' ? $post['reminder'] : null;
            $alert_text = isset($post['alert_text']) && $post['alert_text'] != '' ? $post['alert_text'] : null;
            $wx_logo = isset($post['wx_logo']) && $post['wx_logo'] != '' ? $post['wx_logo'] : null;
            $official_account_code = isset($post['official_account_code']) && $post['official_account_code'] != '' ? $post['official_account_code'] : null;
            $service_mobile = isset($post['service_mobile']) && $post['service_mobile'] != '' ? $post['service_mobile'] : null;
            $official_account_img = isset($post['official_account_img']) && $post['official_account_img'] != '' ? $post['official_account_img'] : null;
            $official_account_head = isset($post['official_account_head']) && $post['official_account_head'] != '' ? $post['official_account_head'] : null;
            $service_time_start = isset($post['service_time_start']) && $post['service_time_start'] != '' ? $post['service_time_start'] : null;
            $service_time_end = isset($post['service_time_end']) && $post['service_time_end'] != '' ? $post['service_time_end'] : null;
            $visiting_card_img = isset($post['visiting_card_img']) && $post['visiting_card_img'] != '' ? $post['visiting_card_img'] : null;
            $visiting_card_name = isset($post['visiting_card_name']) && $post['visiting_card_name'] != '' ? $post['visiting_card_name'] : null;
            $integral_rule_text = isset($post['integral_rule_text']) && $post['integral_rule_text'] != '' ? $post['integral_rule_text'] : null;
            $data['update_time']=time();
            $data['about_us_text']=$about_us_text;
            $data['reminder']=$reminder;
            $data['alert_text']=$alert_text;
            $data['wx_logo']=$wx_logo;
            $data['official_account_code']=$official_account_code;
            $data['service_mobile']=$service_mobile;
            $data['official_account_img']=$official_account_img;
            $data['official_account_head']=$official_account_head;
            $data['service_time_start']=$service_time_start;
            $data['service_time_end']=$service_time_end;
            $data['visiting_card_img']=$visiting_card_img;
            $data['visiting_card_name']=$visiting_card_name;
            $data['about_us_path']=$about_us_path;
            $data['about_us_type']=$about_us_type;
            $data['integral_rule_text']=$integral_rule_text;
            $result=db('config')->where(['id'=>1])->update($data);
            if($result){
                return json(array('code' => '1', 'msg' => '成功'));
            }else{
                return json(array('code' => '0', 'msg' => '失败'));
            }
        }else {
            return json(array('code' => '0', 'msg' => '请求失败'));
        }
    }


    public function index()
    {
        $result=db('config')->where(['id'=>1])->find();
        return json(array('code' => '1', 'msg' => '成功','data'=>$result));
    }


}
